﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BrnMall.Manager.Manager.HaHaTool
{
    /// <summary>
    /// 运维的一些小工具
    /// </summary>
    public static class ToolManager
    {
        /// <summary>
        /// 清除分销商信息重复
        /// </summary>
        /// <param name="sotreid"></param>
        public static void ClearDuplicateDistributor(int sotreid)
        {
            using (var db = new QDMallDatabase())
            {
                db.Execute($@"UPDATE dbo.dis_Distributor SET ISDELETE=1 WHERE id IN(
                select max(ID) from dbo.dis_Distributor where storeid = {sotreid} 
                and OrdersTotal = 0 and isdelete = 0 GROUP BY UserId, StoreId HAVING COUNT(*) > 1
                    )");
            }
        }
    }
}
